﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Gamev1
{
    public class Boss : Enemy
    {
        #region Fields

        public bool canAttack;

        #endregion

        public Boss()
        {
            power = 2;
            hitDelay = 600f;
        }

        public override void update(GameTime gameTime)
        {
            checkCanHit(gameTime);
            Position += Velocity;
            checkAlive();
            animationWalk.Update(gameTime, direction);
            healthBar.Update(gameTime, this);
            AI(gameTime);
            float delay = 5000f;
            if (elapsedTimeAttack >= delay)
            {
                canAttack = true;
            }
        }

        public override void selectRandomPlatform(int randomNumber)
        {
            platformPosition = new Vector2(PlatformPositionList[randomNumber].X, PlatformPositionList[randomNumber].Y - Rectangle.Height - 20);
            this.Position = platformPosition;
        }

        #region Methods

        public override void AI(GameTime gameTime)
        {
            if (canSeeCharacter)
            {
                chase(speed + 2);
                if (currentHealth < calculateHealth(20))
                {
                    power = 3;
                }
            }
            else if (!canSeeCharacter)
            {
                move();
            }
        }

        public Bullet shoot(ContentManager content)
        {
            int aantalTextures = 15;
            float animationDelay = 50f;
            Bullet bullet = new Bullet(aantalTextures, animationDelay);
            bullet.direction = direction;
            for (int i = 1; i <= aantalTextures; i++)
            {
                bullet.animationPath[i - 1] = "Bullets/fireball" + i;
            }
            bullet.loadContent(content);

            if (direction == 0)
            {
                bullet.Position = new Vector2(Position.X - 10, Position.Y + Rectangle.Height / 2);
            }
            else if (direction == 1)
            {
                bullet.Position = new Vector2(Position.X + Rectangle.Width / 2, Position.Y + Rectangle.Height / 2);
            }
            elapsedTimeAttack = 0;
            return bullet;
        }
        #endregion
    }
}
